<div class="row">
 <small>
 <div class="span3 bs-docs-sidebar ">
 	<*include file="<*$controller*>/location.tpl"*>
  </div>
 
  <div class="span9">
    <div class="clearfix txtleft search span9" style="background-color:#f8f8f8; padding:10px; margin:10px 0px;"> 
		<*$school_group.groupname*><*$school_group.schoolname*>，已选学生<*$result.studentnum*>人，每人开卡<*$num*>张，所需<*$result.need*>张卡。<br />
        <*if $result.need gt $result.have*>
        <span style="color:#F00;">未使用卡数量不足，请返回修改学生数量，或请学校购买卡</span>
        <*else*>请选择批量开卡的第一张卡，第一张卡对应第一个班级第一位学生，依次类推<*/if*>
	</div>	    
    <*if $card|@count neq 0*>  
      <form action="/<*$controller*>/opopenmore" method="post" id="form1" onsubmit="return checkhtml();">
       <table class="table table-condensed table-bordered table-hover span9"> 
        <tr class="success">  
		   <td><!--<input type="checkbox" title="全选" name="qxhtml" id="qxhtml" style="background:none" value="1" onclick="xuanhtml();"/>--></td>
           <td><strong>序号</strong></td>
           <td><strong>未使用卡号</strong></td>
        </tr>
      		<*foreach from=$card item=a key =key name=foo*> 
            <tr>
			   <td class="span1"><input type="checkbox" style="background:none" onclick="checkedov(<*$key*>)" name="htmlid[]" id="<*$key*>" value="<*$key*>"/></td>
               <td class="span1"><*$smarty.foreach.foo.iteration*></td> 
               <td class="span1"><*$a*></td> 
            </tr>
    <input type="hidden" name="cardid[]" id="cardid[]" value="<*$a*>"/>
            <*/foreach*>
			<tr>
			<td colspan="5">
    <input type="hidden" name="classlist" id="classlist" value="<*$classlist*>"/>
    <input type="hidden" name="num" id="num" value="<*$num*>"/>
    <input type="hidden" name="need" id="need" value="<*$result.need*>"/>
    <input type="hidden" name="have" id="have" value="<*$result.have*>"/>
    <input type="hidden" name="schoolid" id="schoolid" value="<*$schoolid*>"/>
            <input type="submit" class="btn btn-success" value="批量开卡" />&nbsp;&nbsp;&nbsp;<button type="button" class="btn " onclick="history.back()">返回</button></td></tr>
			</tr>
      </table>
    </form> 
    <input type="hidden" name="ischecked" id="ischecked" value="0"/>
      <*else*>  
             
        <*/if*>  
    </div>
    </small> 
     
<!-- <script type="text/javascript" src="/js/prototype.js"></script>  -->
<script type="text/javascript"> 
  
  
 
       function   ajax_post(){ 
	    var groupsid="<*$groups*>"; 
        $.post("/<*$controller*>/groups/",{"jigouid":groupsid},function(data,statusText){ 
			 $("#jigou").append(data); 
        });  
	 } 
	  
	  $("#jigou").change(function(){
           // $("#city option:gt(0)").remove();  //清空所有城市的信息
            //$("#county option:gt(0)").remove();  //清空所有县级的信息
            var id = this.value;
			var schoolid="<*$schoolid*>";  
			  
            $.post("/<*$controller*>/schoollist/",{"id":id,"sid":schoolid},function(data,statusText){
                 $("#school").html('');
                 $("#school").append(data);
            
            });
        });
		
		$("#school").change(function(){
           // $("#city option:gt(0)").remove();  //清空所有城市的信息
            //$("#county option:gt(0)").remove();  //清空所有县级的信息
            var sid = this.value; 
            $.post("/<*$controller*>/classlist/",{"id":sid},function(data,statusText){
				 
                 $("#class1").html('');
                 $("#class1").append(data);
            
            });
        });
		
	
	 window.onload=function(){
	    ajax_post(); 
	 if( '<*$groups*>'+0 != 0 ){ 
	        
			var id = '<*$groups*>'; 
			var sid = '<*$schoolid*>';  
			 
			$.post("/<*$controller*>/schoollist/",{"id":id,"sid":sid},function(data,statusText){
				 $("#school").html('');
				 $("#school").append(data); 
				});
	    } 
          
	 if('<*$schoolid*>'+0 != 0){   
		   var id = '<*$schoolid*>'; 
		   var cid='<*$classid*>';
			$.post("/<*$controller*>/classlist/",{"id":id,"cid":cid},function(data,statusText){ 
				 $("#class1").html('');
				 $("#class1").append(data); 
				}); 
		   
	 }/* */

 } 
	function sendit(sid){
   window.location='/<*$controller*>/sendit/schoolid/'+sid;   
}  		 
		
	  


function checkhtml(){
	var checkboxs=document.getElementsByName("htmlid[]");
	var clength=checkboxs.length;
	var isc=0;
	for (var i=0;i<clength;i++) {
		var e=checkboxs[i].value;
		var es=document.getElementById(e);
		if(es.checked==true){
			isc++;
		}
	}
	if(isc==0){
		alert('请选择学生');
		return false;
	}else if(isc>1){
		alert('只能选择一个卡号');
		return false;
	}
<*if $result.need gt $result.have*>
		alert('库存不足');
		return false;
<*/if*>	
	return true;
}



function checkedov(id){
	var ischecked=document.getElementById("ischecked");
	var ids=document.getElementById(id);
	if(ids.checked==true){
		ischecked.value=1;
	}
}

function xuanhtml() {
	var qxhtml=document.getElementById("qxhtml");
	var checkboxs=document.getElementsByName("htmlid[]");
	var ischecked=document.getElementById("ischecked");
	if(qxhtml.checked==true){
		for (var i=0;i<checkboxs.length;i++) {
			var e=checkboxs[i];
			e.checked=true;
		}
		ischecked.value=1;
	}else{
		for (var i=0;i<checkboxs.length;i++) {
			var e=checkboxs[i];
			e.checked=false;
		}
		ischecked.value=0;
	}
}

</script>
  
 </div> 